<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .main{
            width:400px;
            align:center;
            border-left:30px;
            border-right:79px;
            background-color: aquamarine;
            margin-left:60px;
            margin-right:40px;
        }
        table{
        width: 100%;
        border-collapse: collapse;
        }

        table caption{
            font-size: 2em;
            font-weight: bold;
            margin: 1em 0;
        }

        th,td{
            border: 1px solid #999;
            text-align: center;
            padding: 20px 0;
        }
    </style>
  
</head>
<body>
    <!-- <script type="text/javascript" src="./js/demo.js">
    </script>  -->
   
   
    <div class="main">
        <h1>列表按钮</h1>
        <hr>
        <span>正式按钮</span>
        <button id="new">新建</button>
        <br>
        <table id ='table'>
            <tr >
                <td>项目一</td>
                <td>项目二</td>
                <td>操作三</td>
            </tr>
                <td>demo1</td>
                <td>demo2</td>
                <td>
                    <button id ='editor'>编辑</button>
                    <button id="delete">删除</button>
                </td>
            </td>
        </th>
    </div>
    <script >
        function a(){
    var table=document.getElementById('table');
    // var length=table.row.length;
    // alert(length)
    var newROw=table.insertRow(-1);
    
    var name1=newROw.insertCell(0);
    var name2=newROw.insertCell(1);
    var name3=newROw.insertCell(2);
    name1.innerHTML='None';
    name2.innerHTML='None';
    name3.innerHTML='<button onclick="c(this)">编辑</button><button onclick="c(this)">删除</button>'
}

function b(button){
    var row = button.parentNode.parentNode;
            row.parentNode.removeChild(row);
}


function c(button){
    var row=button.parentNode.parentNode;
    var name=row.cells[0];
    var name2=row.cell[1];

    var inputname=window.prompt("第一个参数");
    var inputname2=window.prompt("第二个参数")
    name.innerText=inputname;
    name2.innerText=inputname2;
}






new_f=document.getElementById('new')
del_f=document.getElementById('delete')
editor_f=document.getElementById('editor')



new_f.onclick=addEventListener('onclick',a())
del_f.onclick=addEventListener('onclick',b(this))
editor_f.onclick=addEventListener("onclick",c(this))




    </script>
</body>
</html>